package com.hzit.listener;

import javax.servlet.*;
import javax.servlet.annotation.WebListener;
import java.util.ArrayList;
import java.util.List;

/**
 * 类名：
 * 作者：WF
 * 功能：
 */
@WebListener
public class MyServletContextListener implements ServletContextAttributeListener, ServletContextListener {
	@Override
	public void attributeAdded(ServletContextAttributeEvent event) {

	}

	@Override
	public void attributeRemoved(ServletContextAttributeEvent event) {

	}

	@Override
	public void attributeReplaced(ServletContextAttributeEvent event) {

	}

	@Override
	public void contextInitialized(ServletContextEvent sce) {
		List<String> permissions  = new ArrayList<>();
		permissions.add("student:list");
		permissions.add("student:add");
		permissions.add("student:update");
		permissions.add("student:delete");
		permissions.add("classes:list");
		permissions.add("classes:add");
		permissions.add("classes:update");
		permissions.add("classes:delete");
		permissions.add("hello:welcome");
		ServletContext servletContext = sce.getServletContext();
		servletContext.setAttribute("permissions",permissions);
	}

	@Override
	public void contextDestroyed(ServletContextEvent sce) {

	}
}
